有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java有没有办法在systemPath中使用变量来实现systemscope依赖关系?

我目前正在为游戏创建一个mod。我需要在jar中包含所有平台(Win和Mac)以及部分Apache Commons通用的依赖项。由于这将通过Steam Workshop进行分发,我不允许将依赖项jar与mod一起分发,因此所有内容都必须包含在一个jar中

我通过mvn包构建。我的球。xml是:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>Flameborn</groupId>
    <artifactId>InSpire</artifactId>
    <version>0.0.1</version>
    <description>Blind Accessibility Interface for Slay the Spire</description>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <SlayTheSpire.version>01-27-2020</SlayTheSpire.version>
        <ModTheSpire.version>3.8.0</ModTheSpire.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.evacipated.cardcrawl</groupId>
            <artifactId>modthespire</artifactId>
            <version>${ModTheSpire.version}</version>
            <scope>system</scope>
            <systemPath>${SteamPath}/workshop/content/646570/1605060445/ModTheSpire.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>basemod</groupId>
            <artifactId>basemod</artifactId>
            <version>5.0.0</version>
            <scope>system</scope>
            <systemPath>${SteamPath}/workshop/content/646570/1605833019/BaseMod.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.10</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-exec</artifactId>
            <version>1.3</version>
        </dependency>
    </dependencies>
    <profiles>
        <profile>
            <id>platform-windows</id>
            <activation>
                <os>
                    <family>windows</family>
                </os>
            </activation>
            <properties>
                <SteamPath>C:/Program Files (x86)/Steam/steamapps</SteamPath>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>com.megacrit.cardcrawl</groupId>
                    <artifactId>slaythespire</artifactId>
                    <version>${SlayTheSpire.version}</version>
                    <scope>system</scope>
                    <systemPath>${SteamPath}/common/SlayTheSpire/desktop-1.0.jar</systemPath>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.8</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <configuration>
                                    <target>
                                        <copy file="target/${project.artifactId}.jar" tofile="${Steam.path}/common/SlayTheSpire/mods/${project.artifactId}.jar"/>
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>platform-mac</id>
            <activation>
                <os>
                    <family>mac</family>
                </os>
            </activation>
            <properties>
                <SteamPath>${user.home}/Library/Application Support/Steam/steamapps</SteamPath>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>com.megacrit.cardcrawl</groupId>
                    <artifactId>slaythespire</artifactId>
                    <version>${SlayTheSpire.version}</version>
                    <scope>system</scope>
                    <systemPath>${SteamPath}/common/SlayTheSpire/SlayTheSpire.app/Contents/Resources/desktop-1.0.jar</systemPath>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.8</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <configuration>
                                    <target>
                                        <copy file="target/${project.artifactId}.jar" tofile="${Steam.path}/common/SlayTheSpire/SlayTheSpire.app/Contents/Resources/mods/${project.artifactId}.jar"/>
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>com.coveo</groupId>
                <artifactId>fmt-maven-plugin</artifactId>
                <version>2.10</version>
                <configuration>
                    <verbose>false</verbose>
                    <filesNamePattern>.*\.java</filesNamePattern>
                    <skip>false</skip>
                    <skipSortingImports>false</skipSortingImports>
                    <style>google</style>
                    <displayFiles>false</displayFiles>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>format</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <minimizeJar>true</minimizeJar>
                            <filters> 
                                <filter>
                                    <artifact>org.apache.commons:commons-lang3</artifact>
                                    <includes>
                                        <include>**</include>
                                    </includes>
                                </filter> 
                                <filter>
                                    <artifact>org.apache.commons:commons-exec</artifact>
                                    <includes>
                                        <include>**</include>
                                    </includes>
                                </filter> 
                            </filters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>ModTheSpire.json</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>ModTheSpire.json</include>
                </includes>
            </resource>
        </resources>
    </build>
</project>

我发现以下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade (default) on project InSpire: Error creating shaded jar: Some problems were encountered while processing the POMs:
[ERROR] [WARNING] 'dependencies.dependency.systemPath' for com.megacrit.cardcrawl:slaythespire:jar should use a variable instead of a hard-coded path /Users/User/Library/Application Support/Steam/steamapps/common/SlayTheSpire/SlayTheSpire.app/Contents/Resources/desktop-1.0.jar @ line 168, column 19
[ERROR] [WARNING] 'profiles.profile[platform-mac].dependencies.dependency.systemPath' for com.megacrit.cardcrawl:slaythespire:jar should use a variable instead of a hard-coded path /Users/User/Library/Application Support/Steam/steamapps/common/SlayTheSpire/SlayTheSpire.app/Contents/Resources/desktop-1.0.jar @ line 154, column 23
[ERROR] [ERROR] 'dependencies.dependency.systemPath' for com.evacipated.cardcrawl:modthespire:jar must specify an absolute path but is ${SteamPath}/workshop/content/646570/1605060445/ModTheSpire.jar @ line 175, column 19
[ERROR] [ERROR] 'dependencies.dependency.systemPath' for basemod:basemod:jar must specify an absolute path but is ${SteamPath}/workshop/content/646570/1605833019/BaseMod.jar @ line 182, column 19
[ERROR] : 4 problems were encountered while building the effective model for Flameborn:InSpire:0.0.1
[ERROR] [WARNING] 'dependencies.dependency.systemPath' for com.megacrit.cardcrawl:slaythespire:jar should use a variable instead of a hard-coded path /Users/User/Library/Application Support/Steam/steamapps/common/SlayTheSpire/SlayTheSpire.app/Contents/Resources/desktop-1.0.jar @ line 168, column 19
[ERROR] [WARNING] 'profiles.profile[platform-mac].dependencies.dependency.systemPath' for com.megacrit.cardcrawl:slaythespire:jar should use a variable instead of a hard-coded path /Users/User/Library/Application Support/Steam/steamapps/common/SlayTheSpire/SlayTheSpire.app/Contents/Resources/desktop-1.0.jar @ line 154, column 23
[ERROR] [ERROR] 'dependencies.dependency.systemPath' for com.evacipated.cardcrawl:modthespire:jar must specify an absolute path but is ${SteamPath}/workshop/content/646570/1605060445/ModTheSpire.jar @ line 175, column 19
[ERROR] [ERROR] 'dependencies.dependency.systemPath' for basemod:basemod:jar must specify an absolute path but is ${SteamPath}/workshop/content/646570/1605833019/BaseMod.jar @ line 182, column 19

共 (0) 个答案